    document.getElementById('save-btn').addEventListener('click', function () {
        const form = document.querySelector('form');
        const formData = new FormData(form);
        const courseNo = document.body.getAttribute('data-course-no');
        const token = localStorage.getItem('access_token');
        fetch(`/api/course_manage/${courseNo}/`, {
            method: 'PUT',
            body: formData,
            headers: {
                'X-CSRFToken': document.querySelector('[name=csrfmiddlewaretoken]').value,
                'Authorization': `Bearer ${token}`,
            }
        })
        .then(response => {
        if (response.status === 200) {
            alert('课程修改成功！');
            window.location.href = '/manage-course/'; 
        } else {
            alert('课程修改失败，请稍后再试！');
        }
        })
        .catch(error => {
            console.error('错误:', error);
            alert('课程修改失败，请稍后再试！');
        });
    });

    // 放弃更改按钮
    document.getElementById('cancel-btn').addEventListener('click', function () {
        if (confirm('确定要放弃更改吗？')) {
            window.history.back();
        }
    });